package str

// 注意全局变量的定义方式，不可以直接keyboard := ....
var keyboard [8]string = [8]string{
	"abc",  // 2
	"def",  // 3
	"ghi",  // 4
	"jkl",  // 5
	"mno",  // 6
	"pqrs", // 7
	"tuv",  // 8
	"wxyz", // 9
}

var res17 []string

func helper17(track []byte, digits string, index int) {

	if len(track) == len(digits) {
		temp := make([]byte, len(digits))
		copy(temp, track)
		res17 = append(res17, string(temp))
		return
	}

	letters := keyboard[digits[index]-'2']

	for i := 0; i < len(letters); i++ {
		track = append(track, letters[i])
		helper17(track, digits, index+1)
		track = track[:len(track)-1]
	}

}

func letterCombinations(digits string) []string {
	res17 = []string{}
	if digits != "" {

		helper17([]byte{}, digits, 0)
	}
	return res17
}
